#include <gtest/gtest.h>

#include <not_recommended_field_names/basic.pb.h>
#include <not_recommended_field_names/basic.structs.usrv.pb.hpp>

#include <userver/proto-structs/convert.hpp>

USERVER_NAMESPACE_BEGIN

TEST(NotRecommendedFieldNameBasic, Basic) {
    using Struct = not_recommended_field_names::structs::Basic;
    Struct s{};

    s.protected_ = 0;
    s.final_ = 1;
    s.void__ = 2;
    s.float_ = 3;
    s.typeid_ = 4;
    s.new_ = 5;
    s.double_ = 6;

    Struct::ProtobufMessage vanilla{};
    proto_structs::StructToMessage(std::move(s), vanilla);

    ASSERT_EQ(vanilla.protected_(), 0);
    ASSERT_EQ(vanilla.final(), 1);
    ASSERT_EQ(vanilla.void__(), 2);
    ASSERT_EQ(vanilla.float_(), 3);
    ASSERT_EQ(vanilla.typeid_(), 4);
    ASSERT_EQ(vanilla.new_(), 5);
    ASSERT_EQ(vanilla.double_(), 6);
    // Not generated by a plagin.
    ASSERT_EQ(vanilla.minor(), 0);
    ASSERT_EQ(vanilla.major(), 0);
}

TEST(NotRecommendedFieldNameBasic, Upper) {
    using Struct = not_recommended_field_names::structs::Upper;
    Struct s{};
    s.XYandexUid = 1;
    s.Float = 2;
    s.New = 3;

    Struct::ProtobufMessage vanilla{};
    proto_structs::StructToMessage(std::move(s), vanilla);
    ASSERT_EQ(vanilla.xyandexuid(), 1);
    ASSERT_EQ(vanilla.float_(), 2);
    ASSERT_EQ(vanilla.new_(), 3);
}

USERVER_NAMESPACE_END
